I am having a problem on how to updating an existing DataGridView Cell.
Class PTree
{ public string model {get; set;}
public int location {get; set;}
public int ploc {get; set;}
public int cloc {get; set;}
public int nloc {get; set;}
public string name {get; set;}
public string desc {get; set;}
public PTree (string v1, int v2, int v3, int v4, int v5, string v6, string v7)
{
this.model = v1;
this.location=v2;
this.ploc=v3;
this.cloc=v4;
this.nloc=v5;
this.name=v6;
this.desc=v7;
}
}
(model, location, ploc, cloc, nloc, name, desc)
aaaaa, 1, 0, 1, 2, n1, n1desc
aaaaa, 1, 1, 2, 3, n2, n2desc
aaaaa, 1, 2, 3, 9999, n3, n3desc
mysql readin {
ps.Add(new PTree(v1, v2, v3, v4, v5, v6,v7));
}
dataGrideView1.DataSource = ps;
I would like to update the third record 9999 to 4 by just click a btnUpdate.
How could I do that?
Thanks!
Abhishek Srivasatava
17-Nov-2016Hi Mark
I really apologize I have mentioned nloc instead of cloc in the previous program. I think you need to update you store procedure like this just add your cloc value which may be your primary key value or unique value. I mean to say that use your primary key along with your value which you may need to update.
There are many ways by which we can handle this situation. But it depends on the user, which path he may need to follow. As stored procedure is a very easy concept to generate logic.
Mark Mak
15-Nov-2016Abhishek Srivasatava
15-Nov-2016Hi Mark
I think nloc field is a unique column, you need to insert a row in the existing table.
As per my understanding, I have prepared the code for this scenario. You need to create a stored procedure which makes programming easy.
Mark Mak
14-Nov-2016Abhishek Srivasatava
14-Nov-2016